package cn.elves.model.draw.service.algorithm.guarantee;

import cn.elves.model.draw.service.algorithm.BaseDrawAlgorithm;
import cn.elves.model.strategy.entity.po.StrategyDetail;

import java.math.BigDecimal;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.stream.Collectors;

/**
 * ProbabilisticGuaranteeFixedDrawAlgorithm
 * @author 精灵
 * @time 2024-06-19   10:31
 */
public abstract class GuaranteeDrawAlgorithm extends BaseDrawAlgorithm {

    protected Map<Long, String[]> guaranteeAwardMap = new ConcurrentHashMap<>();


    @Override
    public void prepare(Long strategyId, Integer strategyMode, Integer scale, List<StrategyDetail> awardRateList) {
        super.prepare(strategyId,strategyMode,scale,awardRateList);
        List<StrategyDetail> guaranteeAwardList = awardRateList.stream().filter(item -> {
            BigDecimal awardRate = item.getAwardRate();
            int i = awardRate.compareTo(new BigDecimal("0.01"));
            return i <= 0;
        }).collect(Collectors.toList());
        prepareGuaranteeAward(strategyId, guaranteeAwardList);
    }

    public void prepareGuaranteeAward(Long strategyId, List<StrategyDetail> guaranteeAwardList) {
        String[] guaranteeAwardRateArr = makeAwardRateArr(guaranteeAwardList.size(), guaranteeAwardList);
        guaranteeAwardMap.put(strategyId,guaranteeAwardRateArr);
    }
}
